import React, { Component } from 'react';
import { connect } from 'dva';
import { message, Modal, Pagination, Popconfirm, Button, Row, Col } from 'antd';
import styles from './../Users.css';
import moment from 'moment';
import Factory from '../../factory';
import * as datetime from '../../../utils/datetime'
import dataEditCreate from '../../addons/DataEdit'
import dataTableCreate from '../../addons/DataTable'
import DataEditTable from '../../addons/DataEditTable'
import TMinDiviFrom from '../TMinDiviFrom'
import * as compDiviService from '../../../services/AccountDivi';
const daoName = "MinOper";
const ButtonGroup = Button.Group;
const columns = [
    { title: '交易日期', width: 110, sorter: true, key: 'TRTD', caption: "TRTD", render: data => datetime.format(data.TRTD, "yyyy-MM-dd"), dispaly: true, filter: true },
    { title: '营业网点', width: 110, sorter: true, dataIndex: 'OrganName', key: 'OrganName', dispaly: true, filter: true },
    { title: '科目', width: 100, sorter: true, dataIndex: 'ITNM', key: 'ITNM', dispaly: true, filter: true },
    { title: '收费名称', width: 215, sorter: true, dataIndex: 'CHNM', key: 'CHNM', dispaly: true, filter: true },
    { title: '付款帐号', width: 215, sorter: true, dataIndex: 'ACNO', key: 'ACNO', dispaly: true, filter: true },
    { title: '付款户名', width: 260, sorter: true, dataIndex: 'CUNM', key: 'CUNM', dispaly: true, filter: true },
    { title: '收费总额', width: 110, sorter: true, dataIndex: 'HDCH', key: 'HDCH', dispaly: true, filter: true },
    { title: '中间业务类型', width: 180, sorter: true, dataIndex: 'ITNM3', key: 'ITNM3', dispaly: true, filter: true },
];
const columnsDv = [
    { title: '交易日期', width: 100, sorter: true, key: 'TRTD', caption: "TRTD", render: data => datetime.format(data.TRTD, "yyyy-MM-dd"), dispaly: true, filter: true },
    { title: '营业网点', width: 100, sorter: true, dataIndex: 'OrganName', key: 'OrganName', dispaly: true, filter: true },
    { title: '科目', width: 100, sorter: true, dataIndex: 'ITNM', key: 'ITNM', dispaly: true, filter: true },
    { title: '付款帐号', width: 200, sorter: true, dataIndex: 'ACNO', key: 'ACNO', dispaly: true, filter: true },
    { title: '收费总额', width: 100, sorter: true, dataIndex: 'HDCH', key: 'HDCH', dispaly: true, filter: true },
];
const controls = [
    { name: 'TRTD', required: true, type: 'date', label: '交易日期',dataType: "date", min: 1, max: 50, grid: 12 / 24 },
    { name: 'OrganName', required: true, type: 'text', label: '营业网点', min: 1, max: 50, grid: 12 / 24 },
    { name: 'CHTP', required: true, type: 'text', label: '种类码', min: 1, max: 50, grid: 12 / 24 },
    { name: 'ITNM', required: true, type: 'text', label: '科目', min: 1, max: 50, grid: 12 / 24 },
    { name: 'CHNM', required: true, type: 'date', label: '收费名称',  grid: 12 / 24 },
    { name: "ACNO", required: true, type: 'text', label: '付款帐号', min: 1, max: 50, grid: 12 / 24 },
    { name: "CUNM", required: true, type: 'number', label: '付款户名', dataType: "number", grid: 12 / 24 },
    { name: 'TRCT', required: true, type: 'text', label: '单位笔数', min: 1, max: 50, grid: 12 / 24 },
    { name: 'HDCH', required: true, type: 'text', label: '收费总额', min: 1, max: 50, grid: 12 / 24 },
    { name: 'ACTP', required: true, type: 'text', label: '状态', min: 1, max: 50, grid: 12 / 24 },
    { name: 'ITNM3', required: true, type: 'text', label: '中间业务类型', min: 1, max: 50, grid: 12 / 24 },
];
const columnsFhDivi = [
    { title: 'EMID', sorter: true, key: 'EMID', dataIndex: 'EMID', dispaly: false, filter: false },
    { title: '工号', width: 100, sorter: true, key: 'EMNO', dataIndex: 'EMNO', dispaly: true, filter: true },
    { title: '员工姓名', width: 100, sorter: true, key: 'EMNM', dataIndex: 'EMNM', dispaly: true, filter: true },
    { title: '部门名称', width: 120, sorter: true, key: 'OrganName', dataIndex: 'OrganName', dispaly: true, filter: true },
    { title: '付款金额', width: 100, sorter: true, dataIndex: 'DSVL', key: 'DSVL', dispaly: true, filter: true },
];
const controlsFhDivi = [
    { name: 'EMNO', required: true, type: 'text', min: 1, max: 50, label: '工号', grid: 12 / 24 },
    { name: 'EMNM', required: true, type: 'text', label: '员工姓名', min: 1, max: 50, grid: 12 / 24 },
    { name: 'OrganName', required: true, type: 'text', label: '部门名称', min: 1, max: 50, grid: 12 / 24 },
    { name: 'DSVL', required: true, type: 'number', label: '付款金额', grid: 12 / 24, dataType: "number" },
];
const columnsUphmDivi = [
    { title: 'CUID', sorter: true, key: 'CUID', dataIndex: 'CUID', dispaly: false, filter: false },
    { title: '付款户名', width: 100, sorter: true, key: 'CUNM', dataIndex: 'CUNM', dispaly: true, filter: true },
    { title: '付款金额', width: 100, sorter: true, key: 'HDCH', dataIndex: 'HDCH', dispaly: true, filter: true },
];
const EditFrom = dataEditCreate(daoName);
const DataTable = dataTableCreate(daoName);
class MinOper_THForm extends Component {
    constructor(props) {
        super(props);
        this.state = {
            dataChange: false,
            diviList: [],
            seachData: {},
            seachDataSource: [],
            XghmData:{},
            XghmDataSource: [],
            diviDisplay: {
              div1: 'none',
              div2: '',
              div3: 'none',
              lable: '认定',
              lable1: '修改付款户名',
              isRD: true,
              isXg: true,
            }, 
        };
    }
    componentWillReceiveProps(nextProps) {
        if (nextProps.selectedRowKeys.length !== this.props.selectedRowKeys.length) {
            nextProps.selectedRowKeys.map(key => {
                for (let i = 0; i < nextProps.list.length; i++) {
                    if (nextProps.list[i]["ID"] === key) {
                        this.state.diviList[0] = { ...nextProps.list[i] };
                        break;
                    }
                }
            })
        }
    }
    componentDidMount() {
        this.props.dispatch({
            type: `${daoName}/setKeyName`,
            payload: { keyName: "ID", permID: this.props.permID }
        });
        let whereItems = [];
        let WhereCauses = [];
        whereItems.push({
            FieldName: "NTPN1",
            Operator: "in",
            FieldValues: '4,12'
        })
        WhereCauses.push({
            WhereItems: whereItems,
            RelationSign: "AND"
        })
        let seeks=WhereCauses
        this.props.dispatch({
            type: `${daoName}/fetch`,
            payload: { daoName, page: 1, pageSize: 20,seeks }
        });
        this.loadOptionData();
    }
    loadOptionData() {
        let options = []
        controls.map(c => {
            if (c.fetch) {
                let f = c.fetch;
                if (c.type === 'cascader-select') {
                    f.isCascader = true;
                }
                if (c.type !== 'search') {
                    options.push(f);
                }
            }
        })
        if (daoName && options.length > 0) {
            this.props.dispatch({ type: `${daoName}/fetchOptions`, payload: { options } });
        }
    }
    showDiviHandler(ID) {
        if (ID===2){
            if (this.state.diviDisplay.isRD) {
                this.state.diviDisplay.div1='';
                this.state.diviDisplay.div2='none';  
                this.state.diviDisplay.div3='none';  
                this.state.diviDisplay.lable = '返回';
                this.state.diviDisplay.lable1 = '修改付款户名';
                this.state.diviDisplay.isRD = false;
                this.state.diviDisplay.isXg = true;
            } else {
                this.state.diviDisplay.div1 = 'none';
                this.state.diviDisplay.div2 = '';
                this.state.diviDisplay.div3='none'; 
                this.state.diviDisplay.lable = '认定';
                this.state.diviDisplay.lable1 = '修改付款户名';
                this.state.diviDisplay.isRD = true;
                this.state.diviDisplay.isXg = true;
            }
        }else if(ID===3){
            if (this.state.diviDisplay.isXg) {
                this.state.diviDisplay.div3='';
                this.state.diviDisplay.div2='none'; 
                this.state.diviDisplay.div1='none'; 
                this.state.diviDisplay.lable1 = '返回';
                this.state.diviDisplay.lable = '认定';
                this.state.diviDisplay.isXg = false;
                this.state.diviDisplay.isRD = true;
            } else {
                this.state.diviDisplay.div3 = 'none';
                this.state.diviDisplay.div1 = 'none';
                this.state.diviDisplay.div2 = '';
                this.state.diviDisplay.lable1 = '修改付款户名';
                this.state.diviDisplay.lable = '认定';
                this.state.diviDisplay.isXg = true;
                this.state.diviDisplay.isRD = true;
            }
        }
        this.state.diviList = [];
        this.props.dispatch({
            type: `${daoName}/setSelectedRowKeys`,
            payload: { selectedRowKeys: [] }
        });
    }
    addSeachDiviHandler() {
        let dsvl = 0
        let sfze = 0
        if(this.state.diviList.length===0){
            message.error('分配金额失败！请选择一笔中间业务！');
            return;
        }
        sfze = this.state.diviList[0].HDCH
        const form = this.refs.TMinDiviFrom.getForm()
        form.validateFields((err, values) => {
            if (!err) {
                if (values.EMID !== "" && values.DSVL !== "" && values.DSDT !== "") {
                    dsvl = values.DSVL
                }
            }
        })
        if(this.state.seachData.ID<0 || this.state.seachData.No.indexOf(":")>0){
          message.error('分配失败！员工：'+this.state.seachData.Name+'为虚拟员工，不支持业绩分配！请重新选择')
          return;
        }
        //验证：分配的金额        
        if (dsvl === "" || dsvl === 0) {
            message.error('分配金额失败！金额不能为空且不能为零,请输入金额！');
            return;
        }
        if (Math.abs(sfze)>sfze && dsvl>0){
            message.error('分配金额失败！收费总额为负数，分配金额不能大于零！');
            return;
        }
        if (Math.abs(sfze)===sfze && dsvl<0){
            message.error('分配金额失败！收费总额为正数，分配金额不能为小于零！');
            return;
        }
        let data = {
            EMID: this.state.seachData.ID,
            EMNO: this.state.seachData.No,
            EMNM: this.state.seachData.Name,
            OrganName: this.state.seachData.Organization.Name,
            DSVL: dsvl
        }
        let dataSource = this.refs.diviFhTable.state.datas;
        let sumDsvl = 0;
        //验证：添加的员工是否重复，并累加已分配比例是否超出100%
        for (let i = 0; i < dataSource.length; i++) {
            if (Number(dataSource[i]["EMID"]) === Number(data["EMID"])) {
                message.error('分配金额失败！所选员工已分配，请重新选择员工分配！');
                return;
            } else {
                sumDsvl = Number(sumDsvl) + Number(dataSource[i]["DSVL"])
            }
        }
        //验证：已分配比例和新分配比例之和是否超出100%
        let sum = Number(sumDsvl) + Number(data.DSVL)
        if (Math.abs(sum) -Math.abs(sfze)<0.001) {
            dataSource.push(data)
        } else {
            message.error('分配付款金额失败！已分配金额达到总付款金额或分配金额超出剩余付款金额，请核对付款金额！');
            return;
        }
        this.setState({ seachDataSource: dataSource })
    }
    deleteSeachDiviHandler() {
        const keys = this.refs.diviFhTable.getSelectedRowKeys();
        let datas = this.refs.diviFhTable.state.datas;
        let total = this.refs.diviFhTable.state.total;
        let indexs = []
        const keyName = "EMID"
        datas.map((d, k) => {
            for (let i = 0; i < keys.length; i++) {
                if (d[keyName] === keys[i]) {
                    indexs.push(k)
                    total--
                }
            }
        })
        let delDatas = this.refs.diviFhTable.state.delDatas
        for (let j = indexs.length - 1; j >= 0; j--) {
            const k = indexs[j]
            if (datas[k].$state !== 1) {
                delDatas.push(datas[k])
            }
            datas.splice(k, 1)
        }
        this.setState({ seachDataSource: datas })
    }
    submitSeachDiviHandler() {
        const datas = this.refs.diviFhTable.state.datas;
        const witDividatas = this.state.diviList;
        if (witDividatas.length <= 0) {
            message.info('请选择要认定的账户!');
            return;
        }
        let dsvlSum = 0;
        let dataSource = []
        datas.map(d => {
            dsvlSum = Number(dsvlSum) + Number(d.DSVL);
            let data = {
                EMID: Number(d.EMID),
                DSVL: Number(d.DSVL)
            }
            dataSource.push(data);
        })
        let sfze = 0
        sfze=witDividatas[0].HDCH
        if (Math.abs(Math.abs(dsvlSum) - Math.abs(sfze)) >= 0.001) {
            message.info('分配的付款金额必须于收费总额一致');
            return;
        }
        let acids = [];
        acids.push(Number(witDividatas[0].ID))
        this.props.dispatch({
            type: `${daoName}/clieMinDivi`,
            payload: { acids,dataSource }
        });      
        this.state.diviDisplay.div1 = 'none';
        this.state.diviDisplay.div2 = '';
        this.state.diviDisplay.div3='none'; 
        this.state.diviDisplay.lable = '认定';
        this.state.diviDisplay.lable1 = '修改付款户名';
        this.state.diviDisplay.isRD = true;
        this.state.diviDisplay.isXg = true;
        this.state.seachDataSource = [];
        this.state.XghmDataSource = [];
        this.state.diviList =[];
        this.props.dispatch({
            type: `${daoName}/setSelectedRowKeys`,
            payload: { selectedRowKeys: [] }
        });
    }
    addSeachXghmHandler() {
        let hdch = 0              
        let sfze = 0
        if(this.state.diviList.length===0){
            message.error('分配金额失败！请选择一笔中间业务！');
            return;
        }
        sfze = this.state.diviList[0].HDCH
        const form = this.refs.TMinFkhmFrom.getForm()
        form.validateFields((err, values) => {
            if (!err) {
                if (values.CUID !== "" && values.HDCH !== "") {
                    hdch = values.HDCH
                }
            }
        })
        if (hdch === "" || hdch === 0) {
            message.error('分配金额失败！金额不能为空且不能为零,请输入金额！');
            return;
        }
        if (Math.abs(sfze)>sfze && hdch>0){
            message.error('分配金额失败！收费总额为负数，分配金额不能大于零！');
            return;
        }
        if (Math.abs(sfze)===sfze && hdch<0){
            message.error('分配金额失败！收费总额为正数，分配金额不能为小于零！');
            return;
        }
        let data = {
            CUID: this.state.XghmData.ID,
            CUNM: this.state.XghmData.CUNM,
            HDCH: hdch
        }
        let dataSource = this.refs.diviUphmTable.state.datas;
        let sumDsvl = 0;
        //验证：添加的员工是否重复，并累加已分配比例是否超出收费总额
        for (let i = 0; i < dataSource.length; i++) {
            if (Number(dataSource[i]["CUID"]) === Number(data["CUID"])) {
                message.error('分配金额失败！所选客户已分配，请重新选择客户分配！');
                return;
            } else {
                sumDsvl = Number(sumDsvl) + Number(dataSource[i]["HDCH"])
            }
        }
        //验证：已分配金额和收费总额是否一致
        let sum = Number(sumDsvl) + Number(data.HDCH)  
        if (Math.abs(sum) -Math.abs(sfze)<0.001) {
            dataSource.push(data)
        } else {
            message.error('分配付款金额失败！已分配金额达到总付款金额或分配金额超出剩余付款金额，请核对付款金额！');
            return;
        }
        this.setState({ XghmDataSource: dataSource })
    }
    deleteSeachXghmHandler() {
        const keys = this.refs.diviUphmTable.getSelectedRowKeys();
        let datas = this.refs.diviUphmTable.state.datas;
        let total = this.refs.diviUphmTable.state.total;
        let indexs = []
        const keyName = "CUID"
        datas.map((d, k) => {
            for (let i = 0; i < keys.length; i++) {
                if (d[keyName] === keys[i]) {
                    indexs.push(k)
                    total--
                }
            }
        })
        let delDatas = this.refs.diviUphmTable.state.delDatas
        for (let j = indexs.length - 1; j >= 0; j--) {
            const k = indexs[j]
            if (datas[k].$state !== 1) {
                delDatas.push(datas[k])
            }
            datas.splice(k, 1)
        }
        this.setState({ XghmDataSource: datas })
    }
    submitSeachXghmHandler() {
        const datas = this.refs.diviUphmTable.state.datas;
        const witDividatas = this.state.diviList;
        if (witDividatas.length <= 0) {
            message.info('请选择要修改付款户名的账户!');
            return;
        }
        let moid = 0;
        moid=Number(witDividatas[0].ID)
        let dsvlSum = 0;
        let dataSource = []
        datas.map(d => {
            dsvlSum = Number(dsvlSum) + Number(d.HDCH);
            let data = {
                MOID: moid,
                CUID: Number(d.CUID),
                ZSJE: Number(d.HDCH)
            }
            dataSource.push(data);
        })         
        let zhdch = 0
        zhdch=witDividatas[0].HDCH        
        if (Math.abs(Math.abs(dsvlSum) - Math.abs(zhdch)) >= 0.001) {
            message.info('分配的付款金额必须于收费总额一致');
            return;
        }
        this.props.dispatch({
            type: `${daoName}/CLieMinXghmDivi`,
            payload: { daoName,dataSource }
        });     
        this.state.diviDisplay.div1 = 'none';
        this.state.diviDisplay.div2 = '';
        this.state.diviDisplay.div3='none'; 
        this.state.diviDisplay.lable = '认定';
        this.state.diviDisplay.lable1 = '修改付款户名';
        this.state.diviDisplay.isRD = true;
        this.state.diviDisplay.isXg = true;
        this.state.XghmDataSource = [];
        this.state.seachDataSource = [];
        this.state.diviList = [];
        this.props.dispatch({
            type: `${daoName}/setSelectedRowKeys`,
            payload: { selectedRowKeys: [] }
        });
    }
    showTableHandler() {
        let ACNO = "";
        let CUNM = "";
        let TRTD ="";
        let seeks = [];
        const form = this.refs.MinOper_THForm.getForm()
        form.validateFields((err, values) => {
            if (!err) {
                if (values.ACNO === undefined) {
                    values.ACNO = "";
                }
                if (values.CUNM === undefined) {
                    values.CUNM = "";
                }
                if (values.TRTD !== null) {
                    let td =new Date(values.TRTD);
                    let month = td.getMonth()+1;
                    TRTD=td.getFullYear()+'-'+month+'-'+td.getDate()
                }
                ACNO = values.ACNO;
                CUNM = values.CUNM;
            }
        })
        let whereItems = [];
        let WhereCauses = [];
        if (ACNO !== "" && CUNM !== "" && TRTD!=="") {
            whereItems.push({
                FieldName: "ACNO",
                Operator: "like",
                FieldValues: ACNO
            });
            whereItems.push({
                FieldName: "CUNM",
                Operator: "like",
                FieldValues: CUNM
            });
            whereItems.push({
                FieldName: "TRTD",
                Operator: "=",
                FieldValues: TRTD
            })
        } else if (ACNO !== "" && CUNM === "" && TRTD==="") {
            whereItems.push({
                FieldName: "ACNO",
                Operator: "like",
                FieldValues: ACNO
            });
        } else if (ACNO === "" && CUNM !== "" && TRTD==="") {
            whereItems.push({
                FieldName: "CUNM",
                Operator: "like",
                FieldValues: CUNM
            })
        }  else if (ACNO === "" && CUNM === "" && TRTD!=="") {
            whereItems.push({
                FieldName: "TRTD",
                Operator: "=",
                FieldValues: TRTD
            })
        }  else if (ACNO !== "" && CUNM !== "" && TRTD==="") {
            whereItems.push({
                FieldName: "ACNO",
                Operator: "like",
                FieldValues: ACNO
            });
            whereItems.push({
                FieldName: "CUNM",
                Operator: "like",
                FieldValues: CUNM
            })
        } else if (ACNO !== "" && CUNM === "" && TRTD!=="") {
            whereItems.push({
                FieldName: "ACNO",
                Operator: "like",
                FieldValues: ACNO
            });
            whereItems.push({
                FieldName: "TRTD",
                Operator: "=",
                FieldValues: TRTD
            })
        }else if (ACNO === "" && CUNM !== "" && TRTD!=="") {
            whereItems.push({
                FieldName: "CUNM",
                Operator: "like",
                FieldValues: CUNM
            });
            whereItems.push({
                FieldName: "TRTD",
                Operator: "=",
                FieldValues: TRTD
            })
        }
        whereItems.push({
            FieldName: "NTPN1",
            Operator: "=",
            FieldValues: '4'
        })
        WhereCauses.push({
            WhereItems: whereItems,
            RelationSign: "AND"
        })
        if (whereItems.length !== 0)
            seeks = WhereCauses;
        else
            seeks = [];
        this.props.dispatch({
            type: `${daoName}/fetch`,
            payload: { daoName, seeks }
        });
        this.state.diviDisplay.div1 = 'none';
        this.state.diviDisplay.div2 = '';
        this.state.diviDisplay.div3='none'; 
        this.state.diviDisplay.lable = '认定';
        this.state.diviDisplay.lable1 = '修改付款户名';
        this.state.diviDisplay.isRD = true;
        this.state.diviDisplay.isXg = true;
        this.state.XghmDataSource = [];
        this.state.seachDataSource = [];
        this.state.diviList = [];
    }
    seachHandler(data) {
        this.state.seachData = data;
    }
    seachXgHandler(data) {
        this.state.XghmData = data;
    }
    render() {
        let { showEdit, record, offsetHeight, permID, popedomTypes } = this.props
        let height = (offsetHeight - 128) * 0.50 - 41
        let data=[{ value: '1', label: '查询', onClick: this.showTableHandler.bind(this) }]
        let pTypes = popedomTypes[permID]
        if(pTypes.indexOf("6")!==-1){
          data.push({ value: '2', label: this.state.diviDisplay.lable, onClick: this.showDiviHandler.bind(this,2) })
          data.push({ value: '3', label: this.state.diviDisplay.lable1, onClick: this.showDiviHandler.bind(this,3) })
        }  
        const controlsCx = [
            { name: 'ACNO', required: false, type: 'text', label: '账号', grid: 4 / 24, layout: { labelSpan: 8, wrapperSpan: 16 } },
            { name: 'CUNM', required: false, type: 'text', label: '客户名称', grid: 7 / 24, layout: { labelSpan: 8, wrapperSpan: 16 } },
            { name: 'TRTD', required: false, type: 'date', label: '交易日期', grid: 7 / 24, layout: { labelSpan: 8, wrapperSpan: 16 },dataType: "date" },
            { name: 'button', required: false, type: 'button-group', grid: 6 / 24, data: data, layout: { labelSpan: 4, wrapperSpan: 20 } },
        ]
        const controlsFhCx = [
            { name: 'EMID', required: true, type: 'search', label: '员工', grid: 7 / 24, layout: { labelSpan: 9, wrapperSpan: 15 }, fetch: { daoName: 'UserSel', searchColumns: ['No', 'Name'], optionTpl: 'Name', valueTpl: "ID", onSelect: this.seachHandler.bind(this), permID:permID }, dataType: "number", seekType: 2 },
            { name: 'DSVL', required: true, type: 'number', label: '金额', grid: 7 / 24, layout: { labelSpan: 12, wrapperSpan: 12 }, dataType: 'number' },
            { name: 'button', required: false, type: 'button-group', grid: 10 / 24, data: [{ value: '1', label: '添加', onClick: this.addSeachDiviHandler.bind(this) }, { value: '2', label: '删除', onClick: this.deleteSeachDiviHandler.bind(this) }, { value: '3', label: '提交', onClick: this.submitSeachDiviHandler.bind(this) }] },
        ]
        const controlsUphm = [
            { name: 'CUID', required: true, type: 'search', label: '付款客户', grid: 9 / 24, layout: { labelSpan: 9, wrapperSpan: 15 }, fetch: { daoName: 'CompClie', searchColumns: ['ENCD', 'CUNM'], optionTpl: 'CUNM', valueTpl: "ID", onSelect: this.seachXgHandler.bind(this) }, dataType: "number", seekType: 2 },
            { name: 'HDCH', required: true, type: 'number', label: '金额', grid: 5 / 24, layout: { labelSpan: 12, wrapperSpan: 12 }, dataType: 'number' },
            { name: 'button', required: false, type: 'button-group', grid: 10 / 24, data: [{ value: '1', label: '添加', onClick: this.addSeachXghmHandler.bind(this) }, { value: '2', label: '删除', onClick: this.deleteSeachXghmHandler.bind(this) }, { value: '3', label: '提交', onClick: this.submitSeachXghmHandler.bind(this) }] },
        ]
        return (
            <div className={styles.normal} style={{ background: '#fff', marginTop: -16, padding: '5px 5px' }}>
                <div>
                    <div className={styles.create} style={{ paddingBottom: '-16px' }}>
                        <EditFrom ref="MinOper_THForm" daoName={daoName} controls={controlsCx} record={record} clearItemMargin={true} />
                    </div>
                    <DataTable ref="userTable" daoName={daoName} columns={columns} controls={controls} height={height} permID={permID}/>
                    <div style={{ display: this.state.diviDisplay.div2 }} id="showCompDiviDiv" >
                      <TMinDiviFrom permID={permID}/>
                    </div>
                    <div style={{ display: this.state.diviDisplay.div1 }} id="fhCompDiviDiv">
                        <DataEditTable columns={columnsFhDivi} dataSource={this.state.seachDataSource} ref="diviFhTable" 
                        height={150} keyName={"EMID"} daoName={"TMinDivi"} footer={false}  multiSelect={true}/>
                        <EditFrom ref="TMinDiviFrom" daoName={daoName} controls={controlsFhCx} record={record} clearItemMargin={true} />
                    </div>
                    <div style={{ display: this.state.diviDisplay.div3 }} id="UpCompfkhm">
                        <DataEditTable columns={columnsUphmDivi} dataSource={this.state.XghmDataSource} ref="diviUphmTable"
                        height={150} keyName={"CUID"} footer={false}  multiSelect={true}/>
                        <EditFrom ref="TMinFkhmFrom" daoName={daoName} controls={controlsUphm} record={record} clearItemMargin={true} />
                    </div>
                </div>
            </div>
        )
    }
}

function mapStateToProps(state) {
    const { showEdit, record, selectedRowKeys, list, keyName } = state.MinOper;
    const { offsetHeight, userID, orgID, pOrgID, popedomTypes  } = state.menus
    return {
        userID,
        orgID,
        pOrgID,
        popedomTypes,
        showEdit,
        selectedRowKeys,
        list,
        keyName,
        offsetHeight,
        record
    }
}
MinOper_THForm = connect(mapStateToProps)(MinOper_THForm)
export default MinOper_THForm;

let render = (props) => React.createElement(MinOper_THForm, props);
let f = new Factory()
f.set("MinOper_THForm", render)
